import React from "react";
import {View} from "react-native";

class Toast extends React.Component{
    constructor(props){
        super(props);
        this.timer="";
        this.state={
            times:2
        }
    }
    componentDidMount() {
        this.timer=setInterval(() => {
            if(this.state.times<=1){
                clearInterval(this.timer)
                this.props.onclick()
            }else{
                this.setState({times:this.state.times-1})
            }
        },1000);
    }
    componentWillUnmount() {
        clearInterval(this.timer);
    }

    render(){
        return(
            <View style={{backgroundColor:'#000000'}}>
            111
            </View>
        )
    }
}
